package com.shm.you;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**税友
 * 解数独
 * @author SHM
 */
public class Main {

    public static void main(String[] args) {
        char[][] chars = new char[9][9];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 9; i++) {
            String str = sc.nextLine();
            char[] chars1 = str.replaceAll(" ","").toCharArray();
            chars[i] = chars1;
        }
        new Main().sudu(chars);
        for (char[] aChar : chars) {
            for (char c : aChar) {
                System.out.print(c);
            }
            System.out.println();
        }

    }
    boolean[][] line = new boolean[9][9];
    boolean[][] column = new boolean[9][9];
    boolean[][][] block = new boolean[3][9][9];
    boolean valid = false;
    List<int[]> space = new ArrayList<>();

    public void sudu(char[][] chars){
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (chars[i][j] == '0'){
                    space.add(new int[]{i,j});
                }else {
                    int digit = chars[i][j] -'0' - 1;
                    line[i][digit] = column[j][digit] = block[i/3][j/3][digit]=true;
                }
            }
        }
        dfs(chars,0);
    }

    public void dfs(char[][] chars,int index){
        if (index==space.size()){
            valid=true;
            return;
        }
        int[] sp = space.get(index);
        int i=sp[0],j=sp[1];
        for (int digit = 0; digit < 9&&!valid; digit++) {
            if (!line[i][digit]&&!column[j][digit]&&!block[i/3][j/3][digit]){
                line[i][digit] = column[j][digit] = block[i/3][j/3][digit]=true;
                chars[i][j] = (char)(digit+'0'+1);
                dfs(chars,index+1);
                line[i][digit] = column[j][digit] = block[i/3][j/3][digit]=false;
            }

        }
    }

}
